<%@ page language="java" contentType="text/html; charset=utf-8" %>
<% 
String contextPath = request.getContextPath(); 
String forward = (String)session.getAttribute("requestURI");
if (forward == null || forward.endsWith("/zkau"))
	forward = contextPath + "/index.jsp";
else
	session.setAttribute("requestURI", null);
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" href="<%=contextPath%>/images/favicon.ico" type="image/x-icon" />
<title><%=com.pignest.hotel.system.Config.getHotelName()%></title>
<style type="text/css">
body,td,th {
	font-size: 12px;
}
body {
	background-color: #eeeeee;
	overflow:hidden;
}
</style>
<script type="text/javascript" src="<%=contextPath%>/dwr/interface/GlobalAjax.js"></script>
<script type="text/javascript" src="<%=contextPath%>/dwr/engine.js"></script>
<script type="text/javascript" src="<%=contextPath%>/scripts/jquery.js"></script>
<script type="text/javascript" src="<%=contextPath%>/scripts/context.jsp"></script>
<script type="text/javascript" src="<%=contextPath%>/scripts/card.js"></script>

<script type="text/javascript">
if (top.location.href != window.location.href) {
	top.location.href = window.location.href;
}
//dwr.engine.setErrorHandler(function(msg){
//	alert("1" + msg);
//});
function login() {
	var snr = Card.readSerial();
	if (snr == null){
		alert("请连接好读卡器, 并将员工卡放到读卡器上");
		return;
	}
	GlobalAjax.loginByCard(snr, function(data){
		if (data == null) {
			window.location.href = "<%=forward%>";
		} else {
			alert(data);
		}
	});
	return false;
}
function login2() {
	var workNo = $("#workNo").val();
	var password = $("#password").val();
	GlobalAjax.login(workNo, password, {callback:function(data){
		if (data) {
			window.location.href = "<%=forward%>";
		} else {
			alert("登录失败, 请确认你的工号和密码是否输入正确.");
			if (workNo == ''){
				$("#workNo").focus();
			} else {
				$("#password").val("").focus();
			}
		}
	}});
	return false;
}
$(function(){
//	window.history.forward(1);
	$("#workNo").focus();
	$("#workNo").keypress(function(ev){
		if (ev.which == 13) {
			if ($("#workNo").val())
				$("#password").focus();
			return false;
		}
		return true;
	});
	$("#password").keypress(function(ev){
		if (ev.which == 13 && $("#password").val() == '') {
			return false;
		}
		return true;
	});
	if (!checkActivex()) {
		$("#swingCard").hide();
		$("#installPlugin").show().click(function(){
			window.location.href = 'plugin.jsp';
		});
	} else {
		$("#installPlugin").hide();
		$("#swingCard").show().click(login);
	}
});
</script>
</head>

<body>
<object id="bdLockCard" classid="clsid:130D6F39-2FE2-45FB-92B3-AE73D5B2B4EC"  width="0" height="0"></object>
<form method="post" onsubmit="return login2();">
<table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>

		<table border="0" align="center" cellpadding="0" cellspacing="0">
			<tr>
				<td><img src="../../images/login.jpg"></td>
			</tr>
			<tr>
				<td height="30" background="../../images/bg.gif" align="center">
				<table height="100%" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td width="100" align="right">工号：</td>
						<td><input name="workNo" id="workNo" type="text" size="15"
							maxlength="50"></td>
						<td width="80" align="right">密码：</td>
						<td><input name="password" id="password" type="password"
							size="15" maxlength="50"></td>
						
						<td>
							<input type="image" src="../../images/login.gif" width="62" height="22" />
						</td>
						<td width="5">&nbsp;</td>
						<td>
						<input type="image"  id="swingCard" src="../../images/UserCard.png" width="24" height="22"/>
						</td>
						<td>
							<button id="installPlugin" style="display:none;">安装插件</button>
							
						</td>
						
					</tr>
				</table>
				</td>
			</tr>
		</table>
		<br/><br/><br/>
		</td>
  </tr>
  <tr><td align="center" style="font-size: 12px">Copyright © 2009 <%=com.pignest.hotel.system.Config.getHotelName()%> All Rights Reserved</td></tr>
</table>
</form>
</body>
</html>
